#include <iostream>
using namespace std;
/**
 * 
 */
int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int res = 0;
  // a
  e += a / 3;
  b += a / 3;
  res += a % 3;
  a /= 3;

  c += b / 3;
  a += b / 3;
  res += b % 3;
  b /= 3;

  b += c / 3;
  d += c / 3;
  res += c % 3;
  c /= 3;

  c += d / 3;
  e += d / 3;
  res += d % 3;
  d /= 3;

  d += e / 3;
  a += e / 3;
  res += e % 3;
  e /= 3;

  cout << a << " " << b << " " << c << " " << d << " " << e << endl;
  cout << res << endl;

  return 0;
}